// 定义命令边界值
class ParamBoundary {
  constructor(min = -Infinity, minClosed = false, max = 10000000, maxClosed = true) {
    this.min = min;
    this.minClosed = minClosed;
    this.max = max;
    this.maxClosed = maxClosed;
  }

  overstepBoundary(value) {
    const checkedValue = Math.min(this.max, Math.max(this.min, value));
    return !(
      value === checkedValue
      && (this.minClosed || value !== this.min)
      && (this.maxClosed || value !== this.max)
    );
  }

  setParamBoundary({
    min = this.min,
    minClosed = this.minClosed,
    max = this.max,
    maxClosed = this.maxClosed
  }) {
    this.min = min;
    this.minClosed = minClosed;
    this.max = max;
    this.maxClosed = maxClosed;
  }
}

export { ParamBoundary }